; PUSH_REGS ---------------------------------------------------------------------------------------
; 存储寄存器信息与地址
PUSH_REGS_0:
	;mov eax, [PROCMSG_ADDR]
	mov eax, 0
	imul eax, PROC_STACK_SIZE * 4
	
	mov [eax + PROCMSG_MEMBER + 0 * 4], edi
	mov [eax + PROCMSG_MEMBER + 1 * 4], esi
	mov [eax + PROCMSG_MEMBER + 2 * 4], ebp
	mov [eax + PROCMSG_MEMBER + 3 * 4], esp
	mov [eax + PROCMSG_MEMBER + 4 * 4], edx
	mov [eax + PROCMSG_MEMBER + 5 * 4], ecx
	mov [eax + PROCMSG_MEMBER + 6 * 4], ebx
	mov ebx, [esp + 4]
	mov [eax + PROCMSG_MEMBER + 8 * 4], ebx
	mov ebx, [esp + 8]
	mov [eax + PROCMSG_MEMBER + 9 * 4], ebx
	mov ebx, [esp + 12]
	mov [eax + PROCMSG_MEMBER + 10* 4], ebx

	ret

PUSH_REGS_1:
	;mov eax, [PROCMSG_ADDR]
	;mov eax, 1
	imul eax, PROC_STACK_SIZE * 4

	mov [eax + PROCMSG_MEMBER + 0 * 4], edi
	mov [eax + PROCMSG_MEMBER + 1 * 4], esi
	mov [eax + PROCMSG_MEMBER + 2 * 4], ebp
	mov [eax + PROCMSG_MEMBER + 3 * 4], esp
	mov [eax + PROCMSG_MEMBER + 4 * 4], edx
	mov [eax + PROCMSG_MEMBER + 5 * 4], ecx
	mov [eax + PROCMSG_MEMBER + 6 * 4], ebx
	mov ebx, [esp + 4]
	mov [eax + PROCMSG_MEMBER + 8 * 4], ebx
	mov ebx, [esp + 8]
	mov [eax + PROCMSG_MEMBER + 9 * 4], ebx
	mov ebx, [esp + 12]
	mov [eax + PROCMSG_MEMBER + 10* 4], ebx

	ret
; PUSH_REGS END------------------------------------------------------------------------------------

; GET_NEW_EIP----------------------------------------------------------------------------------------
GET_NEW_EIP:
	;mov eax, [PROCMSG_ADDR]
	;mov eax, 1
	imul eax, PROC_STACK_SIZE * 4
	;mov eax, [eax + PROCMSG_MEMBER + 17 * 4]
	;mov [PROCMSG_ADDR], eax
	;imul eax, PROC_STACK_SIZE * 4

	mov eax, [eax + PROCMSG_MEMBER + 8 * 4]
	mov [esp + 4], eax
	mov [esp + 8], cs

	ret

; GET_NEW_EIP END----------------------------------------------------------------------------------

; POP_PRGS----------------------------------------------------------------------------------------------
; 回到原进程
POP_PRGS_0:
	;mov eax, [PROCMSG_ADDR]
	mov eax, 0
	imul eax, PROC_STACK_SIZE * 4
	;mov eax, [eax + PROCMSG_MEMBER + 17 * 4]
	;imul eax, PROC_STACK_SIZE * 4

	mov edi, [eax + PROCMSG_MEMBER + 0 * 4]
	mov esi, [eax + PROCMSG_MEMBER + 1 * 4]
	mov ebp, [eax + PROCMSG_MEMBER + 2 * 4]
	mov esp, [eax + PROCMSG_MEMBER + 3 * 4]
	mov edx, [eax + PROCMSG_MEMBER + 4 * 4]
	mov ecx, [eax + PROCMSG_MEMBER + 5 * 4]
	mov ebx, [eax + PROCMSG_MEMBER + 8 * 4]
	mov [esp + 4], ebx
	mov ebx, [eax + PROCMSG_MEMBER + 9 * 4]
	mov [esp + 8], ebx
	;mov [esp + 8], cs
	mov ebx, [eax + PROCMSG_MEMBER + 10* 4]
	mov [esp + 12], ebx

	ret
	
POP_PRGS_1:
	;mov eax, [PROCMSG_ADDR]
	;mov eax, 1
	imul eax, PROC_STACK_SIZE * 4
	;mov eax, [eax + PROCMSG_MEMBER + 17 * 4]
	;imul eax, PROC_STACK_SIZE * 4

	mov edi, [eax + PROCMSG_MEMBER + 0 * 4]
	mov esi, [eax + PROCMSG_MEMBER + 1 * 4]
	mov ebp, [eax + PROCMSG_MEMBER + 2 * 4]
	;mov esp, [eax + PROCMSG_MEMBER + 3 * 4]
	mov edx, [eax + PROCMSG_MEMBER + 4 * 4]
	mov ecx, [eax + PROCMSG_MEMBER + 5 * 4]
	mov ebx, [eax + PROCMSG_MEMBER + 8 * 4]
	mov [esp + 4], ebx
	mov ebx, [eax + PROCMSG_MEMBER + 9 * 4]
	mov [esp + 8], ebx
	;mov [esp + 8], cs
	mov ebx, [eax + PROCMSG_MEMBER + 10* 4]
	mov [esp + 12], ebx

	ret
; POP_PRGS END------------------------------------------------------------------------------------------
